Hello DXL developer,
string strToken = "(^2$|^2.)"
string strText = "2"
if (matches(strToken, strText)) {
print "match \n"
}
else {
print "no match \n"
}
thsturm - Tue Apr 27 07:56:44 EDT 2010 |
Re: Error in Regexp: matches does not match? Mathias Mamsch, IT-QBase GmbH, Consultant Requirement Engineering and DOORS |
Re: Error in Regexp: matches does not match? Mathias Mamsch - Tue Apr 27 09:41:43 EDT 2010 Mathias Mamsch, IT-QBase GmbH, Consultant Requirement Engineering and DOORS |
Re: Error in Regexp: matches does not match? In v8, your expression seems to match any string that starts with '2', doesn't not match any other string. In v9, it seems to match any string that starts with "2$", not matching any other string (including "2.") I've always had problems with them. In your case, what are you asking? It looks like "any string that's not exactly "2$" or any string that's not exactly one or more "2"s; which is any string. What are you trying to do?
|
Re: Error in Regexp: matches does not match? I have done some tests: (^x$)|(^y.) works. Also ^(x|y.)$
works. |
Re: Error in Regexp: matches does not match? thsturm - Wed Apr 28 06:58:00 EDT 2010 I have done some tests: (^x$)|(^y.) works. Also ^(x|y.)$
works. Wrote this to experiment with regex. Use and abuse as you see fit.
DBE rgx = null
DBE str = null
DBE rst = null
void doit (DB calledfrom)
{
string r = get (rgx)
string s = get (str)
Regexp x = regexp2 r
if (x s) set (rst, s[match 0])
else set (rst, "no match...")
return
}
DB db = centered "Regex Experiment"
rgx = field (db, "Regex:", "", 60, false)
str = field (db, "String:", "", 60, false)
rst = field (db, "Matches:", "", 60, true)
apply (db, " Go ", doit)
show db
|
Re: Error in Regexp: matches does not match? SystemAdmin - Thu May 06 11:34:29 EDT 2010 Wrote this to experiment with regex. Use and abuse as you see fit.
DBE rgx = null
DBE str = null
DBE rst = null
void doit (DB calledfrom)
{
string r = get (rgx)
string s = get (str)
Regexp x = regexp2 r
if (x s) set (rst, s[match 0])
else set (rst, "no match...")
return
}
DB db = centered "Regex Experiment"
rgx = field (db, "Regex:", "", 60, false)
str = field (db, "String:", "", 60, false)
rst = field (db, "Matches:", "", 60, true)
apply (db, " Go ", doit)
show db
|
Re: Error in Regexp: matches does not match? llandale - Thu May 06 16:14:27 EDT 2010
DBE rgx = null
DBE str = null
DBE rst1 = null
DBE rst2 = null
void doit (DB calledfrom)
{
string r = get (rgx)
string s = get (str)
Regexp x1 = regexp r
Regexp x2 = regexp2 r
if (x1 s) set (rst1, s[match 0])
else set (rst1, "no match...")
if (x2 s) set (rst2, s[match 0])
else set (rst2, "no match...")
return
}
DB db = centered "Regex Experiment"
rgx = field (db, "Regex:", "", 60, false)
str = field (db, "String:", "", 60, false)
rst1 = field (db, "Matches1:", "", 60, true)
rst2 = field (db, "Matches2:", "", 60, true)
apply (db, " Go ", doit)
show db
|
Re: Error in Regexp: matches does not match? SystemAdmin - Mon May 17 10:03:43 EDT 2010
DBE rgx = null
DBE str = null
DBE rst1 = null
DBE rst2 = null
void doit (DB calledfrom)
{
string r = get (rgx)
string s = get (str)
Regexp x1 = regexp r
Regexp x2 = regexp2 r
if (x1 s) set (rst1, s[match 0])
else set (rst1, "no match...")
if (x2 s) set (rst2, s[match 0])
else set (rst2, "no match...")
return
}
DB db = centered "Regex Experiment"
rgx = field (db, "Regex:", "", 60, false)
str = field (db, "String:", "", 60, false)
rst1 = field (db, "Matches1:", "", 60, true)
rst2 = field (db, "Matches2:", "", 60, true)
apply (db, " Go ", doit)
show db
I have a string by name "Test" i have a list of groups like 1. AI_Hello-Test_PMs 2. AI_Hello-Test-2.5_PMs 3. AI_Hello-Test-2_PMs so what i am trying to do is for g_All in groupList do { s1 = g_All.name s_ProjectName = "Test" Regexp r = regexp s_ProjectName if(r s1) { print "...."s1 } } the output is .... AI_Hello-Test_PMs ....AI_Hello-Test-2.5_PMs ....AI_Hello-Test-2_PMs in the above code it is displaying all the groups which all are containg the string "Test", but what i want is it should display only the group which has the text "Test" like only the group "AI_Hello-Test_PMs". Please help me in this. Kindly let me know if this possible. Thank you! Regards, Shruthi |
Re: Error in Regexp: matches does not match? Bosch - Tue Jul 05 08:20:50 EDT 2011 Be sure to move your regexp OUTSIDE the loop. The "regexp" command is particularly inefficient. s_ProjectName = "Test" Regexp r = regexp("-" s_ProjectName "_") for g_All in groupList do { ... New code should use "regexp2" instead of "regexp", for reason's I don't know.
|